package com.ruoyi.web.controller.dangerControl;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.dangerControl.domain.HdTrainDept;
import com.ruoyi.dangerControl.service.IHdTrainDeptService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 隐患-培训管理-部门Controller
 *
 * @author lth
 * @date 2023-12-20
 */
@RestController
@RequestMapping("/dangerControl/dept")
public class HdTrainDeptController extends BaseController
{
    @Autowired
    private IHdTrainDeptService hdTrainDeptService;

    /**
     * 查询隐患-培训管理-部门列表
     */
    @PreAuthorize("@ss.hasPermi('dangerControl:dept:list')")
    @GetMapping("/list")
    public TableDataInfo list(HdTrainDept hdTrainDept)
    {
        startPage();
        List<HdTrainDept> list = hdTrainDeptService.selectHdTrainDeptList(hdTrainDept);
        return getDataTable(list);
    }

    /**
     * 导出隐患-培训管理-部门列表
     */
    @PreAuthorize("@ss.hasPermi('dangerControl:dept:export')")
    @Log(title = "隐患-培训管理-部门", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HdTrainDept hdTrainDept)
    {
        List<HdTrainDept> list = hdTrainDeptService.selectHdTrainDeptList(hdTrainDept);
        ExcelUtil<HdTrainDept> util = new ExcelUtil<HdTrainDept>(HdTrainDept.class);
        util.exportExcel(response, list, "隐患-培训管理-部门数据");
    }

    /**
     * 获取隐患-培训管理-部门详细信息
     */
    @PreAuthorize("@ss.hasPermi('dangerControl:dept:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(hdTrainDeptService.selectHdTrainDeptById(id));
    }

    /**
     * 新增隐患-培训管理-部门
     */
    @PreAuthorize("@ss.hasPermi('dangerControl:dept:add')")
    @Log(title = "隐患-培训管理-部门", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HdTrainDept hdTrainDept)
    {
        return toAjax(hdTrainDeptService.insertHdTrainDept(hdTrainDept));
    }

    /**
     * 修改隐患-培训管理-部门
     */
    @PreAuthorize("@ss.hasPermi('dangerControl:dept:edit')")
    @Log(title = "隐患-培训管理-部门", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HdTrainDept hdTrainDept)
    {
        return toAjax(hdTrainDeptService.updateHdTrainDept(hdTrainDept));
    }

    /**
     * 删除隐患-培训管理-部门
     */
    @PreAuthorize("@ss.hasPermi('dangerControl:dept:remove')")
    @Log(title = "隐患-培训管理-部门", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(hdTrainDeptService.deleteHdTrainDeptByIds(ids));
    }
}
